package dev.tools.view.dialogs;

import javax.swing.*;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * User: Nuno
 * Date: 01-10-2013
 * Time: 19:25
 */
public abstract class GridBagDialog extends Dialog {
    private final GridBagConstraints constraints = new GridBagConstraints();

    protected GridBagDialog(JFrame frame) {
        super(frame, new GridBagLayout());
    }

    protected <T extends Component> T setComponent(int x, int y, T component) {
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridx = x;
        constraints.gridy = y;
        getContentsPanel().add(component, constraints);

        return component;
    }

    protected JLabel setComponent(int x, int y, String label) {
        return setComponent(x, y, new JLabel(label));
    }
}
